package com.starsoft.frame.base.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.starsoft.frame.base.bean.BaseUser;
import com.starsoft.frame.core.orm.BaseDao;

@Repository
public class UserDao extends BaseDao<BaseUser, Integer> {

	public BaseUser getUser(Integer userId) {
		return get(userId);
	}

	public void saveUser(BaseUser user) {
		saveOrUpdate(user);
	}

	public BaseUser getUser(String userName) {
		String hql = "from BaseUser where userName=?0";
		List<BaseUser> lu = find(hql, userName);
		if (lu.size() > 0) {
			return lu.get(0);
		}
		return null;
	}

	public BaseUser getUser(String userName, String pwd) {
		String hql = "from BaseUser where userName=?0 and userPwd=?1";
		List<BaseUser> lu = find(hql, userName, pwd);
		if (lu.size() > 0) {
			return lu.get(0);
		}
		return null;
	}
}
